package cn.han.oop;

//本类用做面向对象综合案例
public class TestCar {
    public static void main(String[] args) {
        Car car = new Car();
        Car car1 = new Car();
        Car car2 = new Car();
        car.setBrand("TSL");
        System.out.println(car.getBrand());
        /*6.1给car设置汽车品牌为“TSL”，并打印设置后好的品牌
        6.2给car1的汽车价格设置为10.1w，并打印设置好的价格
        6.3给car2的汽车颜色设置为“尊贵紫”，并打印设置好的颜色
        6.4获取car1对象的颜色，冰结师为什么是这样的打印效果
         */
        car1.setPrice(101000);
        System.out.println(car1.getPrice());
        car2.setColor("尊贵紫");
        System.out.println(car2.getColor());
        System.out.println(car1.getColor());
        /**被private修饰的资源只能在本类中使用*/
//        car.stop();
        car.start();
    }

    //1.定义汽车类，描述汽车这一类型

}
class Car {
    //2.定义属性--成员变量
    //3.对所有属性封装
    private String brand;
    private String color;
    private double length;
    private double price;

    //4.提供小汽车自己的方法
    public void start() {
        System.out.println("启动");
        stop();
    }

    private void stop() {
        System.out.println("停止");
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public double getLength() {
        return length;
    }

    public void setLength(double length) {
        this.length = length;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }
}
